package com.xncoding.testng;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
public class CanShuTets1 {
    @Test(dataProvider = "data0")
    public void test0(String name,int age){
        System.out.println("name =" + name +"; age=" + age);
    }
    @DataProvider(name="data0")
    public Object[][] data0(){
        Object[][] o = new Object[][]{
                {"jack",10},
                {"rose",20}
        };
        return o;
    }

    @Test(dataProvider = "data1")
    public void test1(String name,int age){
        System.out.println("test111方法 name="+name+";age="+age);
    }
    @Test(dataProvider = "data01")
    public void test2(String name,int age){
        System.out.println("test222方法 name="+name+";age="+age);
    }
    @DataProvider(name="data1")
    public Object[][] methodDataTest(Method method){
        Object[][] result=null;
        if(method.getName().equals("test1")){
            result = new Object[][]{
                    {"jack",20},
                    {"rose",25}
            };
        }else if(method.getName().equals("test2")){
            result = new Object[][]{
                    {"jack",50},
                    {"rose",60}
            };
        }
        return result;
    }

    @DataProvider(name="data01")
    @Test(dataProvider = "data02")
    public Object[][] methodDataTest01(String name,int age){
        Object[][] result=null;
        result = new Object[][]{
                {"jack",name},
                {"rose",age}
        };
        return result;
    }
    @DataProvider(name="data02")
    public Object[][] methodDataTest02(String name,int age){
        Object[][] result=null;
        result = new Object[][]{
                {"jack",20},
                {"rose",25}
        };
        return result;
    }
}